<script type="text/javascript" src="./public/js/jquery.datepicker.js"></script>
<script type="text/javascript" src="./public/js/city.js"></script>
<div id="publish_me" class="pub_box">
	<form method="post" id="u_zone_form">
	<div class="pub_area">
		<div class="pub_edit">
			<div id="zone_select_album" class="zone_select_album clearfix">
				<div class="chose_album">
					<a href="javascript:;" class="choose fl slide">选择{lang common/album}</a>
					<i class="choose_r fl slide_r"></i>
					<a class="cancel" href="javascript:;">取消</a>
				</div>
				<span class="fw_count">{sprintf char_check 140}</span>
			</div>
			<div class="pub_expands">
				<?php
					Cache::getInstance()->loadCache('goods_color');
					$cate_options = '';
					FS('Share')->getShareCateOptions(0,$cate_options);
				?>
				<div class="fl pub_expand" style="display:none;">
					<ul class="pub_image_box PUB_IMG">
					</ul>
					<div class="pub_goods_detailed PUB_GOODS_DETAILED" direction="r">
						<div>
							<label>宝贝价格：</label>
							<span class="PGD_PRICE">¥69.99</span>
							<label style="margin:0 0 0 20px;" class="PGD_COMMISSION">可获佣金：</label>
							<span class="PGD_COMMISSION">¥5.99</span>
						</div>
						<div>
							<label>宝贝分类：</label>
							<select class="PGD_GOODSCATE">
								<option value="0">请选择分类</option>
								{$cate_options}
							</select>
							<span class="PGD_GOODSCATESTR"></span>
						</div>
						<div style="margin:5px 0 0 0;">
							<label>宝贝颜色：</label>
							<!--{loop $_FANWE['cache']['goods_color'] $color}-->
							<a class="colorblock" href="javascript:;" title="{$color['name']}" style="background:{if !empty($color['icon'])}url({getimg $color['icon'] 0 0}){else}{$color['color']}{/if};" colorID="{$color['id']}"><span></span></a>
							<!--{/loop}-->
						</div>
						<div style="margin:5px 0 0 0;">
							<label>宝贝描述：</label>
							<input type="text" class="textinput PGD_GOODSALT" style="width:167px;"/>
						</div>
						<a class="pgd_close PGD_CLOSE">关闭</a>
					</div>
					<div class="pub_photo_detailed PUB_PHOTO_DETAILED">
						<div>
							<label>图片描述：</label>
						</div>
						<div>
							<textarea class="textarea PHD_PHOTOALT" style="width:228px; height:64px;"></textarea>
						</div>
						<a class="phd_close PHD_CLOSE">关闭</a>
					</div>
				</div>
				<input type="hidden" class="SHARE_TYPE" name="share_type" value="default"/>
			</div>
			<textarea name="content" class="PUB_TXT pub_txt fl" length="140" position="0" isCN="1"></textarea>
			<input type="button" class="pub_btn fl" value="发表" id="uPubBtn"/>
			<input type="hidden" name="albumid" class="PUB_ALBUM_ID" value="0" />
			<input type="hidden" name="module" value="share" />
			<input type="hidden" name="action" value="save" />
			<!--{if $_FANWE['setting']['share_is_tag'] == 1}-->
			<div class="fl pub_tags PUB_SHARE_TAG_BOX" style="display:none;">
				<span class="fl tag_title">{lang tag}：</span>
				<input type="text" class="fl tag_txt PUB_SHARE_TAG" name="tags" title="{sprintf share_tag_tip $_FANWE['setting']['share_tag_count']}" />
				<ul></ul>
			</div>
			<!--{/if}-->
			<div class="pub_ext">
				<div class="pub_opt fl">
					<a href="javascript:;" onclick="$.Show_Expression(this)" style="background-position:-2px -3px;" class="add_face">表情</a>
					<a class="add_goods" href="javascript:;" onclick="$.Goods_Add(this)" style="background-position:-2px -74px;">商品</a>
					<a style="background-position:-2px -27px;" href="javascript:;" onclick="$.Pic_Add(this)" class="add_pic">图片</a>
					<a class="add_event" href="javascript:;" onclick="$.Event_Add(this)" style="background-position:-2px -97px;">话题</a>
					<a class="add_at" href="javascript:;" onclick="$.At_Add(this)" style="background-position:-3px -615px;">朋友</a>
				</div>
				<div class="pub_out fr">
					<input type="checkbox" checked="checked" name="pub_out_check" value="1">
					<label for="pub_out_check">{lang sync}</label>（<a href="{u settings/bind}" target="_blank">{lang settings}</a>）
				</div>
			</div>
		</div>
	</div>
	<div class="clear"></div>
	</form>
	<div id="zone_album" class="my_album" style="display:none;"><div style="padding:20px; text-align:center;"><img src="./tpl/images/loading.gif" /></div></div>
</div>
<script type="text/javascript">
var ALBUM_MAX_PAGE = 2;
var ALBUM_PAGE = 1;
var ALBUM_IS_LOADING = false;
var ALBUM_SELECT_ID = 0;
var ALBUM_LI_MOUSE = false; 
var PUB_GOODS_DETAILED_OUT = true;
var PUB_IMAGE_DETAILED_TIMEOUT;
var SMALL_TEXT_TIP = '{sprintf char_check 140}';
var BIG_TEXT_TIP = '{sprintf char_check 500}';

jQuery(function($){
	$("#uPubBtn").click(function(){
		var shareType = $("#u_zone_form .SHARE_TYPE").val();
		
		switch(shareType)
		{
			case "look":
				if($('#u_zone_form .PUB_IMG .PUB_SHARTE_GOODS').length < 1)
				{
					$.Show_MiNiTooltip($("#u_zone_form .PUB_LOOK_DAPEI_GOODS"),"U_PUBLISH_LOOK_GOODS_MIN","亲，分享晒货，你还需要上传一个宝贝<br/>哦！",false,1);	
					return false;
				}
				
				if($('#u_zone_form .PUB_IMG .PUB_SHARTE_PIC').length < 1)
				{
					$.Show_MiNiTooltip($("#u_zone_form .PUB_LOOK_DAPEI_PHOTO"),"U_PUBLISH_LOOK_GOODS_MIN","亲，分享晒货，你还需要上传一个宝贝<br/>的照片哦！",false,1);
					return false;
				}
			break;
			
			case "dapei":
				if($('#u_zone_form .PUB_IMG .PUB_SHARTE_PIC').length < 1)
				{
					$.Show_MiNiTooltip($("#u_zone_form .PUB_LOOK_DAPEI_PHOTO"),"U_PUBLISH_DAPEI_IMAGE_MIN","亲，分享搭配，你还需要上传一个搭配<br/>照片哦！",false,1);	
					return false;
				}
			break;
			
			case "activity":
				var value = $("#u_zone_form .pub_expands input[name='title']").val();
				if(!$.checkRequire(value))
				{
					$.Show_MiNiTooltip($("#u_zone_form .pub_expands input[name='title']"),"U_PUBLISH_ACTIVITY_TIP","亲，你还没有输入活动标题哦！",false,1);	
					return false;
				}
				
				value = $("#beginTime").val();
				if($("#timeRange").attr("checked"))
				{
					if(!$.checkRequire(value))
					{
						$.Show_MiNiTooltip($("#beginTime"),"U_PUBLISH_ACTIVITY_TIP","亲，你还没有选择活动开始时间哦！",false,1);	
						return false;
					}
					
					value = $("#endTime").val();
					if(!$.checkRequire(value))
					{
						$.Show_MiNiTooltip($("#endTime"),"U_PUBLISH_ACTIVITY_TIP","亲，你还没有选择活动结束时间哦！",false,1);	
						return false;
					}
				}
				else
				{
					if(!$.checkRequire(value))
					{
						$.Show_MiNiTooltip($("#beginTime"),"U_PUBLISH_ACTIVITY_TIP","亲，你还没有选择活动时间哦！",false,1);	
						return false;
					}
				}
				
				value = $("#u_zone_form .pub_expands input[name='place']").val();
				if(!$.checkRequire(value))
				{
					$.Show_MiNiTooltip($("#u_zone_form .pub_expands input[name='place']"),"U_PUBLISH_ACTIVITY_TIP","亲，你还没有输入活动地点哦！",false,1);	
					return false;
				}
			break;
			
			case "vote":
				var value = $("#u_zone_form .pub_expands input[name='title']").val();
				if(!$.checkRequire(value))
				{
					$.Show_MiNiTooltip($("#u_zone_form .pub_expands input[name='title']"),"U_PUBLISH_VOTE_TIP","亲，你还没有输入投票标题哦！",false,1);	
					return false;
				}
				
				var bln = true;
				$(".VOTE_ITEM").each(function(){
					value = $(this).val();
					if(!$.checkRequire(value))
					{
						$.Show_MiNiTooltip($(this),"U_PUBLISH_VOTE_TIP","亲，投票选项不能为空哦！",false,1);
						bln = false;	
						return false;
					}
				});
				
				if(!bln)
					return false;
			break;
		}
		$.Share_Save(this);
	});
	
	$(".publish_hander .ph_tab").click(function(){
		var thisobj = $(this);
		if(thisobj.hasClass('ph_active'))
			return false;
		
		$(".publish_hander .ph_tab").removeClass('ph_active');
		$(this).addClass('ph_active');
		
		$("#u_zone_form .PUB_TXT").val("");
		$("#u_zone_form .PUB_SHARE_TAG").val("");
		$("#u_zone_form .PUB_SHARE_TAG_BOX ui").html("");
		$("#u_zone_form .PUB_SHARE_TAG_BOX").hide();
		$("#u_zone_form .pub_opt .add_goods").show();
		$("#u_zone_form .pub_opt .add_pic").show();
		$("#u_zone_form .pub_opt .add_event").show();
		var hiddImgs = ","+thisobj.attr('hiddImgs')+",";
		if(hiddImgs.indexOf(",g,") > -1)
			$("#u_zone_form .pub_opt .add_goods").hide();
			
		if(hiddImgs.indexOf(",p,") > -1)
			$("#u_zone_form .pub_opt .add_pic").hide();
			
		if(hiddImgs.indexOf(",e,") > -1)
			$("#u_zone_form .pub_opt .add_event").hide();
		
		$(".tooltip_box").remove();
		$.weeboxs.close();
		$("#u_zone_form .pub_expands").addClass('pub_expands_loading').html("");
		var query = new Object();
		query.type = thisobj.attr('rel');
		
		if(query.type == 'activity' || query.type == 'vote')
		{
			$("#u_zone_form .fw_count").html(BIG_TEXT_TIP);
			$("#u_zone_form .PUB_TXT").attr("length",500);
		}
		else
		{
			$("#u_zone_form .fw_count").html(SMALL_TEXT_TIP);
			$("#u_zone_form .PUB_TXT").attr("length",140);
		}
		
		$.ajax({
			url: SITE_PATH+"services/service.php?m=u&a=publish_share",
			type: "POST",
			data:query,
			dataType: "html",
			success: function(result){
				$("#u_zone_form .pub_expands").removeClass('pub_expands_loading').html(result);
				switch(query.type)
				{
					case "look":
						$.Show_MiNiTooltip(thisobj,"U_PUBLISH_LOOK","亲，分享晒货，至少需要上传一个宝贝<br/>和一个宝贝照片哦！",true);
					break;
					
					case "dapei":
						$.Show_MiNiTooltip(thisobj,"U_PUBLISH_DAPEI","亲，分享搭配，至少需要上传一个搭配<br/>照片哦！",true);
					break;
				}
			}
		});
	});
	
	FANWE.UPLOAD_IMAGE_RESULT_FUNC = function(form){
		if($('.PUB_IMG .PUB_SHARTE_GOODS',form).length >= SETTING.share_goods_count)
		{
			$('.PUB_IMG .PUB_LOOK_DAPEI_GOODS',form).hide();
		}
		else
		{
			$('.PUB_IMG .PUB_LOOK_DAPEI_GOODS',form).show();
		}
		
		if($('.PUB_IMG .PUB_SHARTE_PIC',form).length >= SETTING.share_pic_count)
		{
			$('.PUB_IMG .PUB_LOOK_DAPEI_PHOTO',form).hide();
		}
		else
		{
			$('.PUB_IMG .PUB_LOOK_DAPEI_PHOTO',form).show();
		}
	}
	
	$.Share_Publish_Init($("#u_zone_form"));
	$.Share_Album_Init($("#u_zone_form"),$("#zone_select_album"),$("#zone_album"));
});
</script>